﻿using System;
using System.Configuration;

namespace CloudStorageProvider
{
    public enum Modes
    {
        Live,
        Debug,
        Development
    }

    public class StorageProviderConfiguration : ConfigurationSection
    {
        [ConfigurationProperty("ProviderName", DefaultValue = "AzureBlobStorageProvider", IsRequired = true)]
        public string StorageProviderName
        {
            get { return ConfigurationManager.AppSettings.Get("ProviderName"); }
            set { this["ProviderName"] = value; }
        }

        [ConfigurationProperty("AccountKey", IsRequired = true)]
        public string AccountKey
        {
            get { return (string) this["AccountKey"]; }
            set { this["AccountKey"] = value; }
        }

        [ConfigurationProperty("AccountName", IsRequired = true)]
        public string AccountName
        {
            get { return (string) this["AccountName"]; }
            set { this["AccountName"] = value; }
        }

        [ConfigurationProperty("Mode", IsRequired = false, DefaultValue = Modes.Development)]
        public Modes Mode
        {
            get { return (Modes) Enum.Parse(typeof (Modes), this["Mode"].ToString(), true); }
            set { this["Mode"] = value; }
        }

        [ConfigurationProperty("BaseUri", IsRequired = true)]
        public Uri BaseUri
        {
            get { return new Uri(this["BaseUri"].ToString()); }
            set { this["BaseUri"] = value; }
        }

        [ConfigurationProperty("UseHttps", IsRequired = true)]
        public Boolean UseHttps
        {
            get { return bool.Parse(this["UseHttps"].ToString()); }
            set { this["UseHttps"] = value; }
        }

        [ConfigurationProperty("UseAsynchMethods", IsRequired = true)]
        public Boolean UseAsynchMethods
        {
            get { return bool.Parse(this["UseAsynchMethods"].ToString()); }
            set { this["UseAsynchMethods"] = value; }
        }
    }
}